package cn.wolfcode.luowowo.mgrsite.controller;

import cn.wolfcode.luowowo.acticle.domain.StrategyCommend;
import cn.wolfcode.luowowo.acticle.service.IStrategyCommendService;
import cn.wolfcode.luowowo.acticle.service.IStrategyDetailService;
import cn.wolfcode.luowowo.acticle.service.IStrategyService;
import cn.wolfcode.luowowo.common.query.QueryObject;
import cn.wolfcode.luowowo.common.util.AjaxResult;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("strategyCommend")
public class StrategyCommendController {

    @Reference
    private IStrategyCommendService strategyCommendService;
    @Reference
    private IStrategyService strategyService;

    @Reference
    private IStrategyDetailService strategyDetailService;


    @RequestMapping("/list")
    public String list(Model model, @ModelAttribute("qo")QueryObject qo){
        model.addAttribute("pageInfo", strategyCommendService.query(qo));
        return "strategyCommend/list";
    }

    @RequestMapping("/saveOrUpdate")
    @ResponseBody
    public Object saveOrUpdate(StrategyCommend strategyCommend){
        strategyCommendService.saveOrUpdate(strategyCommend);
        return new AjaxResult();
    }

    @RequestMapping("/delete")
    @ResponseBody
    public Object delete(Long id){
        strategyCommendService.delete(id);
        return new AjaxResult();
    }

    @RequestMapping("/getDetailByStrategyId")
    @ResponseBody
    public Object getDetailByStrategyId(Long strategyId){
        return strategyDetailService.getDetailByStrategyId(strategyId);

    }
    @RequestMapping("/getDetails")
    @ResponseBody
    public Object getDetails(){
        return strategyDetailService.getDetails();

    }
}
